package org.vacoor.nothing.common.dataset.support.reader;

import org.vacoor.nothing.common.dataset.DatasetException;
import org.vacoor.nothing.common.dataset.DatasetReader;

import java.io.BufferedInputStream;
import java.util.Arrays;

/**
 * @author vacoor
 */
public abstract class XlsReader implements DatasetReader {
    private static final byte[] BIFF8_FILE_HEADER = {(byte) 0xD0, (byte) 0xCF, 0x11, (byte) 0xE0};

    @Override
    public boolean support(BufferedInputStream bis) throws DatasetException {
        try {
            byte[] header = BIFF8_FILE_HEADER.clone();
            int readed = bis.read(header);

            return header.length == readed && Arrays.equals(header, BIFF8_FILE_HEADER);
        } catch (Throwable e) {
            throw new DatasetException(e);
        }
    }

}
